#include <Process.h>

Process::Process()
{
	m_timer.reset();
	m_lifeTime = 0;
	m_refreshIntervall = 0;
	m_pauseRunTime = 0;
	m_state = UNINITIALIZED;
}

Process::~Process()
{
	if ( m_pChild)
	{
		m_pChild->VOnAbort();
	}
}

bool Process::IsExpired()
{
	if(m_lifeTime > 0 && m_state == RUNNING)
	{
		return (m_lifeTime > m_timer.getRunTime()); 
	}
	return false;
}

bool Process::IsTimeToUpdate()
{
	if(m_refreshIntervall > 0)
	{
		return m_timer.stopwatch(m_refreshIntervall);
	}
	return true;
}

StrongProcessPtr Process::RemoveChild(void)
{
	if (m_pChild)
	{
        StrongProcessPtr pChild = m_pChild;  // this keeps the child from getting destroyed when we clear it
		m_pChild.reset();
		//pChild->SetParent(NULL);
        return pChild;
	}

	return StrongProcessPtr();
}